package com.java.comprehensive.design.behavioral_model.chain_of_responsibility_pattern;

/**
 * 抽象处理者类
 */
public abstract class Handler {
    public static final Integer NO_ONE = 1;
    public static final Integer NO_THREE = 3;
    public static final Integer NO_SEVEN = 7;

    //改领导处理的请假天数区间
    private int numStart;
    private int numEnd;

    //声明上级领导
    private Handler nextHandler;

    public Handler(int numStart, int numEnd) {
        this.numStart = numStart;
        this.numEnd = numEnd;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    //估计领导处理请假条方法
    protected abstract void handlerLeave(LeaveRequest leave);

    //提交请假条
    protected final void submit(LeaveRequest leave) {

        //该领导审批
        this.handlerLeave(leave);
        if (leave != null && leave.getNum() > this.numEnd) {
            //提交给上级领导
            this.nextHandler.submit(leave);
        } else {
            System.out.println("流程结束");
        }
    }


}
